home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-06-28 | 1.2 KB | 36 lines | [TEXT/ToyS] |
- -- Folder Watcher, a simple agent example.
- -- This script should be built as a stay-open script application.
-
- property targetPath : "" -- path to target folder
-
- property targetFolder : 0 -- alias to target folder (set at startup)
- property modDate : 0 -- modification date of folder when last we checked
-
- on run
- -- Since you probably don't have your drop folder in the same place I do,
- -- I modified the script to ask for it the first time it's run. Clever, no? —Jens
- if length of targetPath is 0 then
- display dialog "Please enter the path to the folder I should watch:" ¬
- default answer ""
- set targetPath to the text returned of the result
- end if
- set targetFolder to alias targetPath -- get an alias to the folder
- end run
-
- on idle
- set newModDate to modification date of (info for targetFolder)
- if modDate = 0 or newModDate > modDate then
- set modDate to newModDate
- folderChanged(targetFolder)
- end if
- return 3 -- Idle time in seconds
- end idle
-
- on folderChanged(f)
- beep
- -- Put anything you want here, and it'll run whenever the folder is modified.
- -- See the “What's New?” sample script for a more sophisticated example,
- -- which figures out what files have been added and displays their names
- -- to the user.
- end folderChanged
-